﻿<%@ WebHandler Language="C#" Class="RemoveCart" %>

using System;
using System.Web;
using System.Collections.Generic;

public class RemoveCart : FiveSistersHandler
{
    
    public override void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        if (IsAuthenticate(context))
        {
            try
            {
                int pi = 0;
                if (context.Request.QueryString["pi"] != null)
                    pi = int.Parse(context.Request.QueryString["pi"].ToString());
                //Product product = new Product().Detail(pi);
                Order order = context.Session[FiveSistersCore.Cart] as Order;
                order.RemoveOrderDetail(pi);
                int sumitem = order.TotalQuantiy();
                int sumprice = order.TotalPrice();
                context.Response.Write("{ \"totalitem\": " + sumitem.ToString() + ", \"totalprice\": " + Formatter.PriceVietNamese(sumprice) + " }");
            }
            catch (Exception ex)
            {
                PMSA.Framework.Log.CLogManager.Write("RemoveCart.ashx", ex.ToString(), "FIVE");
                context.Response.Write("FAIL");
            }
        }     
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}